<template>
<div>
    <div class="title">
        <p class="renyuan">资产合作管理</p>
    </div>
    <div class="sosuo2" style="padding-bottom: 30px;">
        <div>
            <div class="sost4">
                <p class="tit1">公司名称：</p>
                <Input  size="large" placeholder="未编辑" v-model="filter.orgName" style="width:280px;font-size: 14px"></Input>
            </div>
            <div class="sost4">
                <p class="tit1">联系人：</p>
                <Input  size="large" placeholder="未编辑" v-model="filter.contact" style="width:280px;font-size: 14px"></Input>
            </div>
            <div class="sost4">
                <p class="tit1">联系人手机：</p>
                <Input  size="large" placeholder="未编辑" v-model="filter.mobile" style="width:280px;font-size: 14px"></Input>
            </div>
            <div class="sost4">
                <p class="tit1">合约开始日期：</p>
                <Date-picker type="date" placeholder="选择日期" v-model="filter.contractStartDate" style="width:280px;font-size: 14px"></Date-picker>
            </div>
            <div class="sost4">
                <p class="tit1">合约结束日期：</p>
                <Date-picker type="date" placeholder="选择日期" v-model="filter.contractEndDate" style="width:280px;font-size: 14px"></Date-picker>
            </div>
            <div class="sost4">
                <p class="tit1">是否有效：</p>
                <Select v-model="filter.status" clearable class="selc" style="width:280px;font-size: 14px" placeholder="未选择">
                    <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                </Select>
            </div>
            <Button class="congz"  type="primary" style="font-size: 18px;margin-top:15px;" @click="change">查询</Button>
            <span class="resert" @click="handleReset_4"  type="primary" style="font-size: 14px;top: 12px;">重置</span>
        </div>
    </div>
    <div class="tab">
        <Button class="xinz" type="primary" style="font-size: 18px;"><p class="hcg" @click="newadd">新增</p></Button>
        <Table stripe :columns="columns7" :data="list"></Table>
    </div>
    <div class="pag">
        <Page :total="filter.total" :current="filter.pageIndex" :page-size="filter.pageSize" @on-change="changePage_zclist" ></Page>
    </div>
    
</div>   
</template>
<script>
    import Base from '../common/Base.js'
    import {
        mapActions
    } from 'vuex'
    export default {
        mixins:[Base],
        data () {
            return {
                model8: '',
                list1:[],
                filter:{
                    contact:"",
                    orgName:"",
                    mobile:"",
                    status:'',
                    contractStartDate:'',
                    contractEndDate:''
                },
                cityList: [
                    {
                        value: '1',
                        label: '是'
                    },
                    {
                        value: '0',
                        label: '否'
                    }
                ],
                columns7: [
                    {
                        title: '序号',
                        width: 50,
                        key: 'id'
                    },
                    {
                        title: '公司名称',
                        width: 100,
                        key: 't1'
                    },
                    {
                        title: '三证合一编号',
                        width: 147,
                        key: 't2'
                    },
                    {
                        title: '联系人',
                        width: 80,
                        key: 't3'
                    },
                    {
                        title: '联系人手机',
                        width: 120,
                        key: 't4'
                    },
                    {
                        title: '合约生效日期',
                        width: 110,
                        key: 't5'
                    },
                    {
                        title: '合约失效日期',
                        width: 110,
                        key: 't6'
                    },
                    {
                        title: '有效',
                        width: 50,
                        key: 't7'
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width: 170,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'text',
                                        size: 'small',
                                        src:''
                                    },
                                    style: {
                                        background:"url('./static/img/xiugai.png') no-repeat center",
                                        fontWeight: '600',
                                        color:'#5b8cff',
                                        fontSize:'14px',
                                        width: '18px',
                                        height: '18px',
                                        padding: '0px 20px'
                                    },
                                    on: {
                                        click: () => {
                                            this.edit_zclist(params.index)
                                        }
                                    }
                                }, ''),
                                h('Button', {
                                    props: {
                                        type: 'text',
                                        size: 'small',
                                        src:''
                                    },
                                    style: {
                                        background:"url('./static/img/shixiao.png') no-repeat center",
                                        fontWeight: '600',
                                        color:'#5b8cff',
                                        fontSize:'14px',
                                        width: '18px',
                                        height: '18px',
                                        padding: '0px 20px'
                                    },
                                    on: {
                                        click: () => {
                                            this.lapse_zclist(params.index)
                                        }
                                    }
                                }, ''),
                                h('Button', {
                                    props: {
                                        type: 'text',
                                        size: 'small',
                                        src:''
                                    },
                                    style: {
                                        background:"url('./static/img/shanchu.png') no-repeat center",
                                        fontWeight: '600',
                                        color:'#5b8cff',
                                        fontSize:'14px',
                                        width: '18px',
                                        height: '18px',
                                        padding:' 0px 20px'
                                    },
                                    on: {
                                        click: () => {
                                            this.remove_zclist(params.index)
                                        }
                                    }
                                }, '')
                            ]);
                        }
                    }
                ]
            }
        },
        methods: {
            ...mapActions(['checkForm']),
            ...mapActions(['checkzc_form']),
            ...mapActions(['checkzc_formshow']),
            newadd(){
                this.checkzc_form(true); 
                this.form=null;
                this.$router.push({path: '/test3'});
            },
            handleReset_4() {
                this.filter.contact='';
                this.filter.orgName='';
                this.filter.mobile='';
                this.filter.status='';
                this.filter.contractStartDate='';
                this.filter.contractEndDate='';
            },
            change(){
                if(this.filter.contractStartDate != ''){
                    this.filter.contractStartDate=new Date(this.filter.contractStartDate).getTime()
                }
                if(this.filter.contractEndDate != ''){
                    this.filter.contractEndDate=new Date(this.filter.contractEndDate).getTime()
                }
                this.getData_zclist();
            },
            changePage_zclist(page) {
                var _this = this;
                _this.filter.pageIndex = page;
                _this.getData_zclist();
            },
            edit_zclist(index) {
                var _this = this;
                var dataObj = Object.assign({}, _this.list[index]);
                _this.formValidate = dataObj;
                this.checkForm(dataObj);
                this.checkzc_form(true);
                this.checkzc_formshow(false);                
                _this.$router.push({path: '/test3'});
                
            }, 
            lapse_zclist(index) {
                var _this = this;
                var dataObj = Object.assign({}, _this.list[index]);
                _this.formValidate = dataObj;
                this.checkForm(dataObj);
                this.checkzc_form(true);
                this.checkzc_formshow(true);                
                _this.$router.push({path: '/test3'});
            },
            remove_zclist(index){
                var _this = this;
                this.$Modal.confirm({
                    title: '数据失效',
                    content: '<p>确认数据失效</p>',
                    onOk: () => {
                        let deleteUrl = `${_this.dmoreurl}/bizAssetPartner/partnerDel`;
                        _this.$http.post(deleteUrl,{orgCode:_this.list[index].orgCode})
                            .then(response => {
                                _this.getData_zclist();
                                this.$Message.info('数据已失效');
                            })
                    },
                    onCancel: () => {
                        this.$Message.info('取消数据失效');
                    }
                });
            },
            getData_zclist(){
                var _this = this;
                _this.$http.post(`${_this.dmoreurl}/bizAssetPartner/partnerList`,_this.filter)
                .then(function(response) {   
                    _this.list = response.data.data.list;
                    for( let i=0;i<_this.list.length;i++){
                        _this.list[i]['id']=i+1;
                        _this.list[i]['t1']=_this.list[i].orgName;
                        _this.list[i]['t2']=_this.list[i].orgCode;
                        _this.list[i]['t3']=_this.list[i].orgContactor.contact;
                        _this.list[i]['t4']=_this.list[i].orgContactor.mobile;
                        _this.list[i]['t5']=new Date(_this.list[i].assetDeduct.contractStartDate).toLocaleDateString();
                        _this.list[i]['t6']=new Date(_this.list[i].assetDeduct.contractEndDate).toLocaleDateString();
                        if(_this.list[i].saTenant['status']=='1'){
                            _this.list[i]['t7']='是';
                        }else{
                            _this.list[i]['t7']='否';
                        }
                    }
                      _this.filter.total = response.data.data.total;
                });
            }
        },
        created() {      
            this.getData_zclist();
            this.checkForm(null);
        }
    }
</script>
<style lang="scss" >
    .hcg{
        position: relative;
        width: 120px;
        height: 40px;
        top: -7px;
        left: -16px;
        line-height: 40px;
    }
    .ivu-icon-ios-calendar-outline{
        margin-top: 4px;
    }
    .ivu-table-cell{
        text-align: center;
        padding-left: 0px;
        padding-right: 0px;
        font-size: 14px;
    }
    .tab{
        margin:30px;
    }
    .sosuo{
        margin: 0px 30px 0px 30px;
        padding: 32px 0px 30px 0px;
        border-bottom: 1px solid #dbe3f3;
    }
</style>